package com.yosaa.back.enums;
public enum FemaleLungCapacityScore {
    EXCELLENT_100(100, 3400, 3450),
    EXCELLENT_95(95, 3350, 3400),
    EXCELLENT_90(90, 3300, 3350),
    GOOD_85(85, 3150, 3200),
    GOOD_80(80, 3000, 3050),
    PASS_78(78, 2900, 2950),
    PASS_76(76, 2800, 2850),
    PASS_74(74, 2700, 2750),
    PASS_72(72, 2600, 2650),
    PASS_70(70, 2500, 2550),
    PASS_68(68, 2400, 2450),
    PASS_66(66, 2300, 2350),
    PASS_64(64, 2200, 2250),
    PASS_62(62, 2100, 2150),
    PASS_60(60, 2000, 2050),
    FAIL_50(50, 1960, 2010),
    FAIL_40(40, 1920, 1970),
    FAIL_30(30, 1880, 1930),
    FAIL_20(20, 1840, 1890),
    FAIL_10(10, 1800, 1850);

    private final float score;
    private final int freshmanSophomore; // 大一大二标准
    private final int juniorSenior; // 大三大四标准

    FemaleLungCapacityScore(float score, int freshmanSophomore, int juniorSenior) {
        this.score = score;
        this.freshmanSophomore = freshmanSophomore;
        this.juniorSenior = juniorSenior;
    }

    public float getScore() {
        return score;
    }

    public int getFreshmanSophomore() {
        return freshmanSophomore;
    }

    public int getJuniorSenior() {
        return juniorSenior;
    }

    /**
     * 根据肺活量值和年级计算分数
     *
     * @param lungCapacity 肺活量值
     * @param grade        年级
     * @return 分数
     */
    public static float calculateScore(float lungCapacity, String grade) {
        for (FemaleLungCapacityScore standard : FemaleLungCapacityScore.values()) {
            int threshold = grade.equals("大一") || grade.equals("大二")
                    ? standard.getFreshmanSophomore()
                    : standard.getJuniorSenior();
            if (lungCapacity >= threshold) {
                return standard.getScore();
            }
        }
        return 0; // 默认分数
    }
}